package com.ihr360.shared.sequence.dto;

import com.ihr360.commons.entityhandler.Ihr360ContextHandler;
import com.ihr360.shared.entitywithlistener.NumberIdWithTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@EntityListeners(value = {Ihr360ContextHandler.class})
@Table(name = "sc_sequence_no",uniqueConstraints = @UniqueConstraint(columnNames = {"bizModel", "companyId","categoryId"}))
public class Ihr360SequenceNo extends NumberIdWithTime<Long> {
    /**
     * 模块
     */
    @Column(nullable = false, length = 30)
    private String bizModel;

    @Column(length = 40, nullable = false)
    private String companyId;

    /**
     * 序列号分类标志
     */
    @Column(nullable = true, length = 100)
    private String categoryId;

    @Column(length = 21,columnDefinition = "bigint(21) default 1")
    private Long maxId;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private Ihr360SequenceTemplate template;

    public String getBizModel() {
        return bizModel;
    }

    public void setBizModel(String bizModel) {
        this.bizModel = bizModel;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public Long getMaxId() {
        return maxId;
    }

    public void setMaxId(Long maxId) {
        this.maxId = maxId;
    }

    public Ihr360SequenceTemplate getTemplate() {
        return template;
    }

    public void setTemplate(Ihr360SequenceTemplate template) {
        this.template = template;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }
}